package com.example.thirdhomework

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity

class SecondActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_second)

        val textView: TextView = findViewById(R.id.textView)
        val message = intent.getStringExtra("EXTRA_MESSAGE")
        textView.text = message

        val backButton: Button = findViewById(R.id.backButton)
        backButton.setOnClickListener {
            val resultIntent = Intent().apply {
                putExtra("RESULT_KEY", "返回结果")
            }
            setResult(Activity.RESULT_OK, resultIntent)
            finish()
        }
    }
}
